
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "stm32f4xx_hal.h"

void fpga_read(uint8_t addr, uint8_t *pBuffer, uint16_t Num)
{
    *(__IO uint8_t *)((uint32_t)(NAND_DEVICE1 | ADDR_AREA)) = addr;
    /* Get Data into Buffer */
    for(uint16_t index = 0; index < Num; index++)
    {
      *(uint8_t *)pBuffer++ = *(uint8_t *)NAND_DEVICE1;
    }
}

uint8_t fpga_One_read(uint8_t addr)
{
    uint8_t pBuffer;
    *(__IO uint8_t *)((uint32_t)(NAND_DEVICE1 | ADDR_AREA)) = addr;
    // *(__IO uint8_t *)((uint32_t)(NAND_DEVICE1 | CMD_AREA))  = NAND_CMD_AREA_TRUE1;
    /* Get Data into Buffer */
    pBuffer = *(uint8_t *)NAND_DEVICE1;
    return pBuffer;
}

void fpga_write(uint8_t addr, uint8_t *pBuffer, uint16_t Num)
{
    *(__IO uint8_t *)((uint32_t)(NAND_DEVICE1 | ADDR_AREA)) = addr;
    /* Get Data into Buffer */
    for(uint16_t index = 0; index < Num; index++)
    {
      *(__IO uint8_t *)NAND_DEVICE1 = *(uint8_t *)pBuffer++;
    }
}
void fpga_One_write(uint8_t addr, uint8_t pBuffer)
{
    *(__IO uint8_t *)((uint32_t)(NAND_DEVICE1 | ADDR_AREA)) = addr;
    /* Get Data into Buffer */
    *(__IO uint8_t *)NAND_DEVICE1 = pBuffer;
}
